# -*-coding:utf-8-*-
'''
File Create by Author:Backpackerxl
Create File Time:2021/10/13/013 20:57
Program IDE:PyCharm
File Name:BankUser.py
  
'''

import random


class BankUser:

    def __init__(self, user_name, user_sex, user_id, user_phone, user_money, user_password,
                 user_bank_id=None, user_use_state=0):
        self.user_name = user_name
        self.user_sex = user_sex
        self.user_use_state = user_use_state
        self.user_id = user_id
        self.user_phone = user_phone
        self.user_money = user_money
        self.user_password = user_password
        if user_bank_id == None:
            self.user_bank_id = self.user_bank_id()
        else:
            self.user_bank_id = user_bank_id

    def get_user_name(self):
        return self.user_name

    def set_user_name(self, user_name):
        self.user_name = user_name

    def get_user_sex(self):
        return self.user_sex

    def set_user_sex(self, user_sex):
        u_sex = 0 if user_sex == "女" else 1
        self.user_sex = u_sex

    def get_user_use_state(self):
        return self.user_use_state

    def set_user_use_state(self, user_use_state):
        self.user_use_state = user_use_state

    def get_user_id(self):
        return self.user_id

    def set_user_id(self, user_id):
        self.user_id = user_id

    def get_user_phone(self):
        return self.user_phone

    def set_user_phone(self, user_phone):
        self.user_phone = user_phone

    def get_user_money(self):
        return self.user_money

    def set_user_money(self, user_money):
        self.user_money = user_money

    def get_user_password(self):
        return self.user_password

    def set_user_password(self, user_password):
        self.user_password = user_password

    def get_user_bank_id(self):
        return self.user_bank_id

    def user_bank_id(self):
        bank_id = ''
        for i in range(6):
            ch = chr(random.randrange(ord('0'), ord('9') + 1))
            bank_id += ch
        return bank_id

    def user_to_dic(self):
        return {"user_bank_id": self.user_bank_id,
                "user_name": self.user_name,
                "user_sex": self.user_sex,
                "user_use_state": self.user_use_state,
                "user_id": self.user_id,
                "user_phone": self.user_phone,
                "user_money": int(self.user_money),
                "user_password": self.user_password}
